package pl.com.mol.eatool.model.wsdlmodel;

import pl.com.mol.eatool.model.EANamespace;
import pl.com.mol.eatool.model.eamodel.eatype.EAComplexType;
import pl.com.mol.eatool.model.eamodel.eatype.EAInterfaceClass;
import pl.com.mol.eatool.model.eamodel.eatype.EAType;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Created by mol1 on 28.06.14.
 */
public class WSDLStructure {

    public WSDLStructure(EAInterfaceClass interfaceClass) {
        setTargetNamespace(interfaceClass.getNamespace());
        mapHeders(interfaceClass.getHeaders());
    }

    public Map<String, EANamespace> getNamespaces() {
        Map<String, EANamespace> wsdlNamespaceMap = new HashMap<>();

        addNamespace(wsdlNamespaceMap, getHeaders());
        addNamespace(wsdlNamespaceMap, getFaults());

        return wsdlNamespaceMap;
    }

    //------------------------------------------------------------------------------------------------------------------

    private void addNamespace(Map<String, EANamespace> namespaceMap, Set<? extends WSDLType> types) {
        for (WSDLType type : types) {
            namespaceMap.put(type.getNamespace().getPrefix(), type.getNamespace());
        }
    }

    private void mapHeders(Set<EAComplexType> eaHeaders) {

    }

    private void mapFaults(Set<EAComplexType>)

    //------------------------------------------------------------------------------------------------------------------

    /**
     * WSDL target namespace
     */
    private EANamespace targetNamespace;

    /**
     * Headers
     */
    private Set<WSDLHeader> headers = new HashSet<>();

    /**
     * Faults
     */
    private Set<WSDLFault> faults = new HashSet<>();

    /**
     * WSDL types
     */
    private Set<WSDLType> types = new HashSet<>();

    /**
     * WSDL port type (1.1), interface (2.0)
     */
    private Set<WSDLInterface> interfaces;

    /**
     * WSDL binding
     */
    private Set<WSDLBinding> bindings = new HashSet<>();

    /**
     * WSDL service
     */
    private WSDLService service;

    public EANamespace getTargetNamespace() {
        return targetNamespace;
    }

    public void setTargetNamespace(EANamespace targetNamespace) {
        this.targetNamespace = targetNamespace;
    }

    public Set<WSDLHeader> getHeaders() {
        return headers;
    }

    public void setHeaders(Set<WSDLHeader> headers) {
        this.headers = headers;
    }

    public Set<WSDLFault> getFaults() {
        return faults;
    }

    public void setFaults(Set<WSDLFault> faults) {
        this.faults = faults;
    }

    public Set<WSDLType> getTypes() {
        return types;
    }

    public void setTypes(Set<WSDLType> types) {
        this.types = types;
    }

    public Set<WSDLInterface> getInterfaces() {
        return interfaces;
    }

    public void setInterfaces(Set<WSDLInterface> interfaces) {
        this.interfaces = interfaces;
    }

    public Set<WSDLBinding> getBindings() {
        return bindings;
    }

    public void setBindings(Set<WSDLBinding> bindings) {
        this.bindings = bindings;
    }

    public WSDLService getService() {
        return service;
    }

    public void setService(WSDLService service) {
        this.service = service;
    }
}
